//
//  AppDelegate.m
//  MoreStarLiveTelecast
//
//  Created by babbage on 16/8/17.
//  Copyright © 2016年 babbage. All rights reserved.
//

#import "AppDelegate.h"
#import "IQKeyboardManager.h"
#import "ChoseWindowRoot.h"
#import "ZJWelcomeViewController.h"
//#import "LoginVC.h"

//友盟
#import "UMSocial.h"
#import "UMSocialWechatHandler.h"
#import "UMSocialQQHandler.h"
#import "UMSocialSinaSSOHandler.h"

//通知
#import "ZJNotification.h"

@interface AppDelegate ()

@property (nonatomic,strong) NSTimer *myRegistTimer;//倒计时

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    //初始化窗口
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    //根控制器
    [ChoseWindowRoot choseFirstVC];
    //注册通知
    [[ZJNotification shareCenter] createAllNotifacation];
    //键盘初始化
    [self IQKeyBoardInit];
    //友盟
    [self UmengInit];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    if ([[BMKUserData userData] allowGetLoaction]) {
        [GJCFNotificationCenter postNotificationName:StarLocationService object:nil];
    }
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

#pragma mark --- IQKeyBoard ---
-(void)IQKeyBoardInit
{
    //隐藏IQ  Toolbar
    [[IQKeyboardManager sharedManager] disableToolbarInViewControllerClass:[UIViewController class]];
    [[IQKeyboardManager sharedManager] setEnable:YES];
}
#pragma mark -- 友盟初始化 --
-(void)UmengInit
{
    //  注册友盟
    [UMSocialData setAppKey:UmengKEY];
    
    //  注册QQ 微信 新浪
    [UMSocialQQHandler setQQWithAppId:@"1105067230" appKey:@"OQsatf1wKTkqF5VW" url:ShareURL];
    [UMSocialWechatHandler setWXAppId:@"wx6331e9f3100a2435" appSecret:@"1f4d84cf1aa2892e0940788bd5bcf928" url:ShareURL];
    [UMSocialSinaSSOHandler openNewSinaSSOWithAppKey:@"3040221202"
                                              secret:@"1b9efde9d6d5143b4ed893a9f3cebe41"
                                         RedirectURL:@"http://sns.whalecloud.com/sina2/callback"];
}
#pragma mark -- App回调 --
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    BOOL result = [UMSocialSnsService handleOpenURL:url];
    if (result == FALSE) {
        if ([url.host isEqualToString:@"safepay"]) {
            NSLog(@"支付宝支付");
        }
    }
    return result;
}
@end
